package com.hsd.mapper;

import com.hsd.entity.Account;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IAccountMapper {

    /**
     * 查询所有账户信息
     *
     * @return
     */
    @Results(id = "accountResultMap",value = {
            @Result(id = true, property = "acc", column = "a_acc"),
            @Result(property = "money", column = "a_money")
    })
    @Select("select * from t_account")
    List<Account> selectAll();

    /**
     * 通过账号查询账户信息
     * @param acc
     * @return
     */
    @ResultMap("accountResultMap")
    @Select("select * from t_account where a_acc = #{acc}")
    Account selectByAcc(String acc);

    /**
     * 修改账户余额
     *
     * @param acc
     * @param money
     * @return
     */
    @Update("update t_account set a_money = a_money + #{money} where a_acc = #{acc}")
    int updateMoney(@Param("acc") String acc, @Param("money") Double money);
}
